ℹ️Как компьютеры находят простые числа в тысячи раз быстрее, чем ты на бумажке
📌 Что делает решето Эратосфена
Находит все простые числа от 1 до N — быстро, эффективно и без перебора делителей. ➡️ Как это работает
▪️ Создаём массив от 2 до N
▪️ Берём первое невычеркнутое число p
▪️ Вычеркиваем все кратные p
▪️ Переходим к следующему невычеркнутому числу
▪️ Повторяем, пока p² <= N
Пример на Python:
def eratosthenes(n): sieve = [True] * (n+1) sieve[0:2] = [False, False] for i in range(2, int(n**0.5) + 1): if sieve[i]: for j in range(i*i, n+1, i): sieve[j] = False return [i for i, prime in enumerate(sieve) if prime]
ℹ️Как компьютеры находят простые числа в тысячи раз быстрее, чем ты на бумажке
📌 Что делает решето Эратосфена
Находит все простые числа от 1 до N — быстро, эффективно и без перебора делителей. ➡️ Как это работает
▪️ Создаём массив от 2 до N
▪️ Берём первое невычеркнутое число p
▪️ Вычеркиваем все кратные p
▪️ Переходим к следующему невычеркнутому числу
▪️ Повторяем, пока p² <= N
Пример на Python:
def eratosthenes(n): sieve = [True] * (n+1) sieve[0:2] = [False, False] for i in range(2, int(n**0.5) + 1): if sieve[i]: for j in range(i*i, n+1, i): sieve[j] = False return [i for i, prime in enumerate(sieve) if prime]
In many cases, the content resembled that of the marketplaces found on the dark web, a group of hidden websites that are popular among hackers and accessed using specific anonymising software.“We have recently been witnessing a 100 per cent-plus rise in Telegram usage by cybercriminals,” said Tal Samra, cyber threat analyst at Cyberint.The rise in nefarious activity comes as users flocked to the encrypted chat app earlier this year after changes to the privacy policy of Facebook-owned rival WhatsApp prompted many to seek out alternatives.
The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.